package com.shrct.businessprocess.product.impl;

import com.shrct.businessprocess.product.RCDerivedFullServiceProductSpecification;
import com.shrct.businessprocess.product.RCProductSpecification;
import com.shrct.businessprocess.product.RCServiceInfo;
import com.shrct.businessprocess.product.RCServiceLevel;
import com.shrct.businessprocess.product.RCServiceResponseTime;
import com.shrct.businessprocess.product.impl.RCProductSpecificationImpl;
import com.shrct.businessprocess.product.proxy.RCDerivedFullServiceProductSpecificationProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCDERIVEDFULLSERVICEPRODUCTSPECIFICATION_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcderivedfullserviceproductspecification")
public class RCDerivedFullServiceProductSpecificationImpl extends BaseModelObject implements RCDerivedFullServiceProductSpecification {
  public RCDerivedFullServiceProductSpecificationImpl() {
    super();
  }
  
  public RCDerivedFullServiceProductSpecificationImpl(final RCProductSpecification original) {
    super();
    this.original = original;
  }
  
  private String code;
  
  public String getCode() {
    return this.code;
  }
  
  public RCDerivedFullServiceProductSpecification setCode(final String code) {
    this.code = code;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "monthes", column = @Column(name = "serviceType_monthes") ), @AttributeOverride(name = "workaround", column = @Column(name = "serviceType_workaround") ) } )
  @AssociationOverrides(value = { @AssociationOverride(name = "serviceLevel", joinColumns = @JoinColumn(name = "serviceType_serviceLevel") ), @AssociationOverride(name = "serviceResponseTime", joinColumns = @JoinColumn(name = "serviceType_serviceResponseTime") ), @AssociationOverride(name = "serviceDuration", joinColumns = @JoinColumn(name = "serviceType_serviceDuration") ) } )
  private RCServiceInfo serviceType = com.shrct.businessprocess.product.RCServiceInfo.create();
  
  public RCServiceInfo getServiceType() {
    return this.serviceType;
  }
  
  public RCDerivedFullServiceProductSpecification setServiceType(final RCServiceInfo serviceType) {
    this.serviceType = serviceType;
    return this;			
    
  }
  
  @JoinColumn(name = "original_id")
  @ManyToOne(targetEntity = RCProductSpecificationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductSpecification original;
  
  public RCProductSpecification getOriginal() {
    return this.original;
  }
  
  public RCDerivedFullServiceProductSpecification setOriginal(final RCProductSpecification original) {
    this.original = original;
    return this;			
    
  }
  
  public RCServiceLevel getServiceLevel() {
    RCServiceLevel _serviceLevel = this.serviceType.getServiceLevel();
    return _serviceLevel;
  }
  
  public RCServiceResponseTime getServiceResponseTime() {
    RCServiceResponseTime _serviceResponseTime = this.serviceType.getServiceResponseTime();
    return _serviceResponseTime;
  }
  
  public Integer getMonthes() {
    Integer _monthes = this.serviceType.getMonthes();
    return _monthes;
  }
  
  public static RCDerivedFullServiceProductSpecification create(final RCProductSpecification original, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.product.RCDerivedFullServiceProductSpecification rCDerivedFullServiceProductSpecification = new com.shrct.businessprocess.product.impl.RCDerivedFullServiceProductSpecificationImpl(
    	original
    );
    objectFactory.create(rCDerivedFullServiceProductSpecification);
    return rCDerivedFullServiceProductSpecification;			
    
  }
  
  public static RCDerivedFullServiceProductSpecification createRCDerivedFullServiceProductSpecificationImpl(final RCProductSpecification original, final IObjectFactory objectFactory, final Procedure1<RCDerivedFullServiceProductSpecification> init) {
    com.shrct.businessprocess.product.RCDerivedFullServiceProductSpecification rCDerivedFullServiceProductSpecification = new com.shrct.businessprocess.product.impl.RCDerivedFullServiceProductSpecificationImpl(
    	original
    );
    objectFactory.create(rCDerivedFullServiceProductSpecification);
    init.apply(rCDerivedFullServiceProductSpecification);
    
    return rCDerivedFullServiceProductSpecification;			
    
  }
  
  public RCDerivedFullServiceProductSpecificationProxy toProxy() {
    com.shrct.businessprocess.product.proxy.RCDerivedFullServiceProductSpecificationProxy proxy = new com.shrct.businessprocess.product.proxy.RCDerivedFullServiceProductSpecificationProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
